Extract tar.gz file to a directory and create the directory if not exist
发布时间:2023-05-09
归档分类:
标签:

Description

I can run the following command to extract the tar.gz file to 'somedir' directory, But this command requires that the directory already exists.

tar -xvf somefile.tar.gz -C somedir

Solution

Following command can extract the somefile.tar.gz file to a directory that does not exist.

tar -xf somefile.tar.gz --one-top-level=somedir